{include file='common/head'}
<body>
<div class="x-body">
    <form class="layui-form" method="post" action="{:url('index/xinxi/addvideo')}" enctype="multipart/form-data">


        <div class="layui-form-item">
            <label for="username" class="layui-form-label">
                <span class="x-red">*</span>视频
            </label>
            <input type="file" name="video" value="上传视频">
        </div>
        <div class="layui-form-item">
            <label for="username" class="layui-form-label">
                <span class="x-red">*</span>用户id
            </label>
            <div class="layui-input-inline">
                <input type="text" name="uid" placeholder="请填写用户id" id="jname" class="layui-input" lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="username" class="layui-form-label">
                <span class="x-red">*</span>群组
            </label>
            <div class="layui-input-inline">
                <select name="gid" id="jname"  style="width:96px; " lay-verify="required">
                    {volist name="group" id="rs"}
                    <option value=""></option>
                    <option value="{$rs.id}">{$rs.group_name}</option>
                    {/volist}
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="username" class="layui-form-label">
                <span class="x-red"></span>数量
            </label>
            <div class="layui-input-inline">
                <input type="text" name="number" required="" lay-verify="required"
                       autocomplete="off" class="layui-input">
                <select name="unit">
                    <option value="1">吨</option>
                    <option value="2">公斤</option>
                    <option value="3">斤</option>
                    <option value="4">个</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="username" class="layui-form-label">
                <span class="x-red"></span>价格
            </label>
            <div class="layui-input-inline">
                <input type="text" name="price" required="" lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label for="desc" class="layui-form-label">
                地址
            </label>
            <div class="layui-input-block">
                <input type="text"  lay-verify="required" name="address" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label for="desc" class="layui-form-label">
                内容
            </label>
            <div class="layui-input-block">
                <input type="text"  lay-verify="required" name="content" autocomplete="off" class="layui-input" placeholder="详细介绍你的产品，包括质量特色和一些服务">
            </div>
        </div>
      	
        <div class="layui-form-item">
            <label for="L_repass" class="layui-form-label">
            </label>
            <button  class="layui-btn" lay-filter="add" lay-submit="">
                发布
            </button>
        </div>
    </form>
</div>
<script>
    layui.use(['form','layer'], function(){
        $ = layui.jquery;
        var form = layui.form
            ,layer = layui.layer;

        //自定义验证规则
        form.verify({
            nikename: function(value){
                if(value.length < 5){
                    return '昵称至少得5个字符啊';
                }
            }
            ,pass: [/(.+){6,12}$/, '密码必须6到12位']
            ,repass: function(value){
                if($('#L_pass').val()!=$('#L_repass').val()){
                    return '两次密码不一致';
                }
            }
        });

        // //监听提交
        // form.on('submit(add)', function(data){
        //     console.log(data);
        //     var url="";
        //     $.ajax({
        //         type: "post",
        //         async:false,
        //         url: "{:url('index/xinxi/addvideo')}",
        //         data: data.field,
        //         success:function (res) {
        //             console.log(res);
        //         }
        //     })
        //     //发异步，把数据提交给php
        //     //layer.alert("增加成功", {icon: 6},function () {
        //         // 获得frame索引
        //         //var index = parent.layer.getFrameIndex(window.name);
        //         //关闭当前frame
        //        // parent.layer.close(index);
        //   //  });
        //     return false;
        // });


    });
</script>
<script>
    layui.use('upload', function() {
        var $ = layui.jquery
            , upload = layui.upload;

        //普通图片上传
        var uploadInst = upload.render({
            elem: '#test1'
            , url: '/upload/'
            , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#demo1').attr('src', result); //图片链接（base64）
                });
            }
            , success: function (res) {
                //如果上传失败
                if (res.code > 0) {
                    return layer.msg('上传成功');
                    //return false;
                }
                //上传成功
            }
            //, error: function () {
                //演示失败状态，并实现重传
                //var demoText = $('#demoText');
                //demoText.html('<span style="color: #FF5722; width: 1000px;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
               // demoText.find('